
Property changes on: .
___________________________________________________________________
Modified: svn:ignore
   - build

ivy

target

.project

gradle-core.iml

cobertura.ser

build-resolver

.gradle

   + build

ivy

target

.project

gradle-core.iml

cobertura.ser

build-resolver

.gradle
extractor
tools
.gradle
build
build-resolver


Index: src/main/groovy/org/gradle/api/dependencies/AbstractDependency.groovy
===================================================================
--- src/main/groovy/org/gradle/api/dependencies/AbstractDependency.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/dependencies/AbstractDependency.groovy	(working copy)
@@ -23,6 +23,10 @@
 import org.gradle.api.Project
 
 /**
+ * The base Dependency model.
+ * <p/>
+ * Basically defines functions to check, within the constructor, that the user description is valid.
+ *
 * @author Hans Dockter
 */
 abstract class AbstractDependency implements Dependency {
@@ -33,7 +37,6 @@
     Project project
 
     AbstractDependency(Set confs, Object userDependencyDescription, Project project) {
-        boolean valid = true
         if (!(isValidType(userDependencyDescription)) || !isValidDescription(userDependencyDescription)) {
             throw new UnknownDependencyNotation("Description $userDependencyDescription not valid!")
         }
@@ -42,6 +45,9 @@
         this.project = project
     }
 
+    /**
+     * Checks to see if the user provided description of the dependency matches this dependency type.
+     */
     abstract boolean isValidDescription(Object userDependencyDescription)
 
     abstract Class[] userDepencencyDescriptionType()
Index: src/main/groovy/org/gradle/api/dependencies/ArtifactDependency.groovy
===================================================================
--- src/main/groovy/org/gradle/api/dependencies/ArtifactDependency.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/dependencies/ArtifactDependency.groovy	(working copy)
@@ -24,6 +24,12 @@
 import org.gradle.api.internal.dependencies.DependenciesUtil
 
 /**
+ * Artifact dependency is just a file, usually a jar file - no xml descriptor etc.
+ * <p/>
+ * Gradle needs a repository somewhere where this artifact can be found, but there is no xml descriptor required
+ * in the repository. If there is one, it is ignored. In the simplest case such a repository is a folder on your local
+ * machine.
+ * 
  * @author Hans Dockter
  */
 class ArtifactDependency extends AbstractDependency {
@@ -35,6 +41,7 @@
         super(confs, userDependencyDescription, project)
     }
 
+
     boolean isValidDescription(Object userDependencyDescription) {
         if (!DependenciesUtil.hasExtension(userDependencyDescription)) { return false }
         int elementCount = (userDependencyDescription as String).split(':').size()
Index: src/main/groovy/org/gradle/api/dependencies/ClientModule.groovy
===================================================================
--- src/main/groovy/org/gradle/api/dependencies/ClientModule.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/dependencies/ClientModule.groovy	(working copy)
@@ -26,6 +26,23 @@
 
 
 /**
+ * Client module dependencies enable you to declare transitive dependencies directly in your build script. Client
+ * module dependencies can be nested.
+ * <p/>
+ * <pre>
+ * addClientModule(confs: ['compile'], id: "org.codehaus.groovy:groovy-all:1.5.4") {
+ *   addDependency("commons-cli:commons-cli:1.0:jar")
+ *   addClientModule("org.apache.ant:ant:1.7.0") {
+ *     addDependency("org.apache.ant:ant-launcher:1.7.0:jar")
+ *     addDependency("org.apache.ant:ant-junit:1.7.0")
+ *   }
+ * }
+ * </pre>
+ * <p/>
+ * This declares a dependency of your project on Groovy. Groovy itself has dependencies. But Gradle does not look
+ * for an xml descriptor to gure them out but gets the information from the build file. The dependencies of a client
+ * module can be normal module dependencies or artifact dependencies or another client module.
+ *
  * @author Hans Dockter
  */
 // todo the setProject method of Dependency is only needed by the ProjectDependency. We need to refactor.
Index: src/main/groovy/org/gradle/api/dependencies/Dependency.java
===================================================================
--- src/main/groovy/org/gradle/api/dependencies/Dependency.java	(revision 674)
+++ src/main/groovy/org/gradle/api/dependencies/Dependency.java	(working copy)
@@ -21,6 +21,8 @@
 import java.util.Set;
 
 /**
+ * Basic interface of a Dependency.
+ *
 * @author Hans Dockter
 */
 public interface Dependency {
Index: src/main/groovy/org/gradle/api/dependencies/ModuleDependency.groovy
===================================================================
--- src/main/groovy/org/gradle/api/dependencies/ModuleDependency.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/dependencies/ModuleDependency.groovy	(working copy)
@@ -29,6 +29,15 @@
 import org.gradle.api.internal.dependencies.DependencyDescriptorFactory
 
 /**
+ * A Module Dependency is the same as an artifact dependency except that you don't specify
+ * a file extension.
+ * <p/>
+ * For Module dependencies, Gradle looks in the repositories if there is either a Maven pom
+ * file or an ivy.xml file for this module. If there is no such XML file, Gradle either tries
+ * to download a jar with the same signature as the module dependency or throws an exception
+ * (or both, if this jar can't be found). It is configurable whether a XML descriptor for a
+ * module dependency is required. This is a per-repository configuration.
+ * 
  * @author Hans Dockter
  */
 class ModuleDependency extends AbstractDependency {
Index: src/main/groovy/org/gradle/api/dependencies/ProjectDependency.groovy
===================================================================
--- src/main/groovy/org/gradle/api/dependencies/ProjectDependency.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/dependencies/ProjectDependency.groovy	(working copy)
@@ -21,8 +21,10 @@
 import org.gradle.api.Project
 
 /**
-* @author Hans Dockter
-*/
+ * A project that a module depends on which is a part of a multi-project build.
+ *
+ * @author Hans Dockter
+ */
 class ProjectDependency extends AbstractDependency {
     String dependencyConfiguration = Dependency.DEFAULT_CONFIGURATION
 
Index: src/main/groovy/org/gradle/api/internal/dependencies/DefaultDependencyManager.groovy
===================================================================
--- src/main/groovy/org/gradle/api/internal/dependencies/DefaultDependencyManager.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/internal/dependencies/DefaultDependencyManager.groovy	(working copy)
@@ -37,6 +37,8 @@
 import org.gradle.util.Clock
 
 /**
+ * Handles dependencies{} closure calls in Gradle build files.
+ * 
  * @author Hans Dockter
  */
 class DefaultDependencyManager extends DefaultDependencyContainer implements DependencyManager {
@@ -128,7 +130,6 @@
             return resolveCache[conf]
         }
         ivy = getIvy()
-        //        ivy.configure(new File('/Users/hans/IdeaProjects/gradle/gradle-core/ivysettings.xml'))
         ModuleDescriptor moduleDescriptor = moduleDescriptorConverter.convert(this)
         ResolveOptions resolveOptions = new ResolveOptions()
         resolveOptions.setConfs([conf] as String[])
Index: src/main/groovy/org/gradle/api/internal/dependencies/DependencyFactory.groovy
===================================================================
--- src/main/groovy/org/gradle/api/internal/dependencies/DependencyFactory.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/internal/dependencies/DependencyFactory.groovy	(working copy)
@@ -36,15 +36,18 @@
         Dependency dependency = null
 
         if (userDependencyDescription instanceof Dependency) {
+            // dependency object already created, setting project and configuration
             dependency = userDependencyDescription
             dependency.project = project
             dependency.confs = confs
         } else {
+            // try to construct the dependency from each DependencyFactory
             for (Class clazz in dependencyImplementations) {
                 try {
                     dependency = clazz.newInstance(confs, userDependencyDescription, project)
                     break
                 } catch (UnknownDependencyNotation e) {
+                    // todo why ignore?
                     // ignore
                 }
             }
Index: src/main/groovy/org/gradle/api/internal/project/DefaultScriptHandler.groovy
===================================================================
--- src/main/groovy/org/gradle/api/internal/project/DefaultScriptHandler.groovy	(revision 674)
+++ src/main/groovy/org/gradle/api/internal/project/DefaultScriptHandler.groovy	(working copy)
@@ -25,6 +25,8 @@
 import org.gradle.api.Project
 
 /**
+ * Compiles and runs Gradle build script and registers missing method and parameter hooks.
+ *
  * @author Hans Dockter
  */
 class DefaultScriptHandler implements ScriptHandler {
@@ -37,9 +39,11 @@
         Clock clock = new Clock()
         CompilerConfiguration configuration = createBaseCompilerConfiguration()
         GroovyShell groovyShell = new GroovyShell(project.buildScriptClassLoader, new Binding(), configuration)
+        // Parse the build script
         Script script = groovyShell.parse(scriptText, project.buildFileName)
         replaceMetaclass(script, project)
         logger.debug("Timing: Creating script took: " + clock.time)
+        // Run the script
         script
     }
 
@@ -95,6 +99,9 @@
         project.buildFileName.replaceAll('\\.', '_')
     }
 
+    /**
+     * Register missing method and property hooks to delegate to the project object and run the script.
+     */
     private Script replaceMetaclass(Script script, Project project) {
         ExpandoMetaClass projectScriptExpandoMetaclass = new ExpandoMetaClass(script.class, false)
         projectScriptExpandoMetaclass.methodMissing = {String name, args ->
Index: src/main/groovy/org/gradle/api/internal/project/ScriptHandler.java
===================================================================
--- src/main/groovy/org/gradle/api/internal/project/ScriptHandler.java	(revision 674)
+++ src/main/groovy/org/gradle/api/internal/project/ScriptHandler.java	(working copy)
@@ -4,11 +4,9 @@
 import org.gradle.api.Project;
 
 /**
- * Created by IntelliJ IDEA.
- * User: hans
- * Date: Jul 1, 2008
- * Time: 10:32:38 AM
- * To change this template use File | Settings | File Templates.
+ * Defines the ScriptHandler contract which handles creating, loading and saving scripts.
+ *
+ * @author Hans Dockter
  */
 public interface ScriptHandler {
     Script createScript(Project project, String scriptText);
Index: src/main/groovy/org/gradle/api/plugins/JavaPlugin.java
===================================================================
--- src/main/groovy/org/gradle/api/plugins/JavaPlugin.java	(revision 674)
+++ src/main/groovy/org/gradle/api/plugins/JavaPlugin.java	(working copy)
@@ -31,6 +31,7 @@
 import org.gradle.api.*;
 import org.gradle.api.tasks.util.FileSet;
 import org.gradle.util.GroovyJavaHelper;
+import static org.gradle.api.tasks.util.CollectionUtils.map;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -124,8 +125,7 @@
 
     void configureDependencyManager(Project project, JavaPluginConvention javaPluginConvention) {
         DependencyManager dependencies = project.getDependencies();
-        dependencies.addConfiguration(
-                new Configuration(JavaPlugin.COMPILE, Visibility.PRIVATE, null, null, false, null));
+        dependencies.addConfiguration(new Configuration(COMPILE, Visibility.PRIVATE, null, null, false, null));
         dependencies.addConfiguration(new Configuration(RUNTIME, Visibility.PRIVATE, null, new String[]{COMPILE}, true, null));
         dependencies.addConfiguration(new Configuration(TEST_COMPILE, Visibility.PRIVATE, null, new String[]{COMPILE}, false, null));
         dependencies.addConfiguration(new Configuration(TEST_RUNTIME, Visibility.PRIVATE, null, new String[]{RUNTIME, TEST_COMPILE}, true, null));
@@ -160,13 +160,4 @@
         return compile;
     }
 
-    private Map map(Object... objects) {
-        Map map = new HashMap();
-        assert objects.length % 2 == 0;
-        for (int i = 0; i < objects.length; i += 2) {
-            map.put(objects[i], objects[i + 1]);
-        }
-        return map;
-    }
-
 }
Index: src/main/groovy/org/gradle/api/Settings.java
===================================================================
--- src/main/groovy/org/gradle/api/Settings.java	(revision 674)
+++ src/main/groovy/org/gradle/api/Settings.java	(working copy)
@@ -26,13 +26,15 @@
 import groovy.lang.Closure;
 
 /**
+ * Stores the basic settings for a project such as build paths, dependencies, repos etc...
+ *
  * @author Hans Dockter
  */
 public interface Settings {
     /**
      * The paths to the project which should take part in this build additional to the project containing the
-     * settings file, which takes always in part in the build.
-     *
+     * settings file, which always takes part in the build.
+     * <p/>
      * A project path in the settings file is slightly different from a project path you use in your build scripts.
      * A settings project path is always relative to the directory containing the settings file.
      *
@@ -43,7 +45,7 @@
     /**
      * Adds project paths of projects which should take part in this build, additional to the project containing the
      * settings file, which takes always in part in the build.
-     *
+     * <p/>
      * A project path in the settings file is slightly different from a project path you use in your build scripts.
      * A settings project path is always relative to the directory containing the settings file.
      *
@@ -76,7 +78,7 @@
 
     /**
      * @param jarRepoUrls A list of urls of repositories to look for artifacts only. This is needed
-     * if only the pom is in the MavenRepo repository (e.g. jta).
+     *                    if only the pom is in the MavenRepo repository (e.g. jta).
      */
     DualResolver addMavenRepo(String[] jarRepoUrls);
 
Index: src/main/groovy/org/gradle/api/tasks/util/CollectionUtils.java
===================================================================
--- src/main/groovy/org/gradle/api/tasks/util/CollectionUtils.java	(revision 0)
+++ src/main/groovy/org/gradle/api/tasks/util/CollectionUtils.java	(revision 0)
@@ -0,0 +1,26 @@
+package org.gradle.api.tasks.util;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Hans Dockter
+ * @author Antony Stubbs
+ */
+public class CollectionUtils {
+
+    /**
+     * Constructs a Map out of pairs of variables in a list of Objects.
+     *
+     * @param objects list of objects to construct map from. Must have an even number of objects.
+     * @return a Map of pairs.
+     */
+    public static Map map(Object... objects) {
+        Map map = new HashMap();
+        assert objects.length % 2 == 0;
+        for (int i = 0; i < objects.length; i += 2) {
+            map.put(objects[i], objects[i + 1]);
+        }
+        return map;
+    }
+}
Index: src/main/groovy/org/gradle/initialization/DefaultSettings.groovy
===================================================================
--- src/main/groovy/org/gradle/initialization/DefaultSettings.groovy	(revision 674)
+++ src/main/groovy/org/gradle/initialization/DefaultSettings.groovy	(working copy)
@@ -110,7 +110,7 @@
     }
 
     // todo We don't have command query separation here. This si a temporary thing. If our new classloader handling works out, which
-    // adds simply the build script jars to the context classloader we can remove the return argument and simplify our design. 
+    // simply adds the build script jars to the context classloader we can remove the return argument and simplify our design. 
     URLClassLoader createClassLoader() {
         URLClassLoader classLoader = Thread.currentThread().contextClassLoader
         def dependency = null
Index: src/main/groovy/org/gradle/Main.java
===================================================================
--- src/main/groovy/org/gradle/Main.java	(revision 674)
+++ src/main/groovy/org/gradle/Main.java	(working copy)
@@ -35,13 +35,14 @@
 import joptsimple.OptionException;
 
 import java.util.List;
-import java.util.Arrays;
 import java.io.File;
+import java.io.IOException;
 
 /**
+ * Main entry point for Gradle.
+ *
  * @author Hans Dockter
  */
-// todo the main method is too long. Extract methods.
 public class Main {
     private static Logger logger = LoggerFactory.getLogger(Main.class);
 
@@ -53,6 +54,7 @@
     public final static String IMPORTS_FILE_NAME = "gradle-imports";
     public final static String NL = System.getProperty("line.separator");
 
+    // command line options
     private static final String NON_RECURSIVE = "n";
     private static final String NO_JVM_TERMINATION = "S";
     private static final String BOOTSTRAP_DEBUG_INFO = "B";
@@ -84,33 +86,9 @@
         String embeddedBuildScript = null;
         StartParameter startParameter = new StartParameter();
 
-        OptionParser parser = new OptionParser() {
-            {
-                acceptsAll(WrapUtil.toList(NON_RECURSIVE, "non-recursive"), "Do not execute primary tasks of childprojects.");
-                acceptsAll(WrapUtil.toList(NO_JVM_TERMINATION), "Don't trigger a System.exit(0) for normal termination. Used for Gradle's internal testing.");
-                acceptsAll(WrapUtil.toList(NO_DEFAULT_IMPORTS, "no-imports"), "Disable usage of default imports for build script files.");
-                acceptsAll(WrapUtil.toList(NO_SEARCH_UPWARDS, "no-search-upward"), "Don't search in parent folders for a settings.gradle file.");
-                acceptsAll(WrapUtil.toList(NO_CACHING, "no-caching"), "No caching of compiled build scripts.");
-                acceptsAll(WrapUtil.toList(VERSION, "version"), "Print version info.");
-                acceptsAll(WrapUtil.toList(DEBUG, "debug"), "Log in debug mode (includes normal stacktrace).");
-                acceptsAll(WrapUtil.toList(QUIET, "quiet"), "Log errors only.");
-                acceptsAll(WrapUtil.toList(IVY_DEBUG, "ivy-debug"), "Set Ivy log level to debug (very verbose).");
-                acceptsAll(WrapUtil.toList(IVY_QUIET, "ivy-quiet"), "Set Ivy log level to quiet.");
-                acceptsAll(WrapUtil.toList(STACKTRACE, "stacktrace"), "Print out the stacktrace also for user exceptions (e.g. compile error).");
-                acceptsAll(WrapUtil.toList(FULL_STACKTRACE, "full-stacktrace"), "Print out the full (very verbose) stacktrace for any exceptions.");
-                acceptsAll(WrapUtil.toList(TASKS, "tasks"), "Show list of all available tasks and there dependencies.");
-                acceptsAll(WrapUtil.toList(PROJECT_DIR, "project-dir"), "Specifies the start dir for Gradle. Defaults to current dir.").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(GRADLE_USER_HOME, "gradle-user-home"), "Specifies the gradle user home dir.").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(PLUGIN_PROPERTIES_FILE, "plugin-properties-file"), "Specifies the plugin.properties file.").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(BUILD_FILE, "buildfile"), "Specifies the build file name (also for subprojects). Defaults to build.gradle.").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(SYSTEM_PROP, "systemprop"), "Set system property of the JVM (e.g. -Dmyprop=myvalue).").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(PROJECT_PROP, "projectprop"), "Set project property for the build script (e.g. -Pmyprop=myvalue).").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(EMBEDDED_SCRIPT, "embedded"), "Specify an embedded build script.").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(BOOTSTRAP_DEBUG_INFO, "bootstrap-debug"), "Specify a text to be logged at the beginning (e.g. used by Gradle's bootstrap class.").withRequiredArg().ofType(String.class);
-                acceptsAll(WrapUtil.toList(HELP, "?"), "Shows this help message");
-            }
-        };
+        OptionParser parser = buildOpionParser();
 
+        // parse cli options - check for errors
         OptionSet options = null;
         try {
             options = parser.parse(args);
@@ -120,22 +98,22 @@
             return;
         }
 
+        // print help
         if (options.has(HELP)) {
             parser.printHelpOn(System.out);
         }
 
+        if (options.has(VERSION)) {
+            System.out.println(new GradleVersion().prettyPrint());
+            System.exit(0);
+        }
+
         configureLogger(options);
 
-
         if (options.hasArgument(BOOTSTRAP_DEBUG_INFO)) {
             logger.debug(options.argumentOf(BOOTSTRAP_DEBUG_INFO));
         }
 
-        if (options.has(VERSION)) {
-            System.out.println(new GradleVersion().prettyPrint());
-            System.exit(0);
-        }
-
         if (!GUtil.isTrue(gradleHome)) {
             logger.error("The gradle.home property is not set. Please set it and try again.");
             exitWithSuccess(options);
@@ -145,37 +123,14 @@
         startParameter.setDefaultImportsFile(
                 options.has(NO_DEFAULT_IMPORTS) ? null : new File(gradleHome + '/' + IMPORTS_FILE_NAME));
 
-        if (options.has(SYSTEM_PROP)) {
-            List<String> props = options.argumentsOf(SYSTEM_PROP);
-            logger.info("Running with System props: " + props);
-            for (String keyValueExpression : props) {
-                String[] elements = keyValueExpression.split("=");
-                startParameter.getSystemPropertiesArgs().put(elements[0], elements.length == 1 ? "" : elements[1]);
-            }
-        }
+        processSystemProperties(startParameter, options);
 
-        if (options.has(PROJECT_PROP)) {
-            List<String> props = options.argumentsOf(PROJECT_PROP);
-            logger.info("Running with Project props: " + props);
-            for (String keyValueExpression : props) {
-                String[] elements = keyValueExpression.split("=");
-                startParameter.getProjectProperties().put(elements[0], elements.length == 1 ? "" : elements[1]);
-            }
-        }
+        processProjectProperties(startParameter, options);
 
         startParameter.setRecursive(!options.has(NON_RECURSIVE));
         startParameter.setSearchUpwards(!options.has(NO_SEARCH_UPWARDS));
 
-        if (options.has(PROJECT_DIR)) {
-            startParameter.setCurrentDir(new File(options.argumentOf(PROJECT_DIR)));
-            if (!startParameter.getCurrentDir().isDirectory()) {
-                logger.error("Error: Directory " + startParameter.getCurrentDir().getCanonicalFile() + " does not exists!");
-                exitWithSuccess(options);
-                return;
-            }
-        } else {
-            startParameter.setCurrentDir(new File(System.getProperty("user.dir")));
-        }
+        if (processProjectDir(startParameter, options)) return;
 
         startParameter.setGradleUserHomeDir(
                 options.hasArgument(GRADLE_USER_HOME) ?
@@ -199,14 +154,12 @@
             embeddedBuildScript = options.argumentOf(EMBEDDED_SCRIPT);
         }
 
-        logger.debug("gradle.home= " + gradleHome);
-        logger.debug("Project dir: " + startParameter.getCurrentDir());
-        logger.debug("Gradle user home: " + startParameter.getGradleUserHomeDir());
-        logger.info("Recursive: " + startParameter.isRecursive());
-        logger.info("Buildfilename: " + startParameter.getBuildFileName());
-        logger.debug("Plugin properties: " + startParameter.getPluginPropertiesFile());
-        logger.debug("Default imports file: " + startParameter.getDefaultImportsFile());
+        printCliSettings(gradleHome, startParameter);
 
+        runBuild(buildTimeClock, embeddedBuildScript, startParameter, options);
+    }
+
+    private static void runBuild(Clock buildTimeClock, String embeddedBuildScript, StartParameter startParameter, OptionSet options) throws Throwable {
         try {
             startParameter.setTaskNames(options.nonOptionArguments());
             if (!GUtil.isTrue(startParameter.getTaskNames()) && !options.has(TASKS)) {
@@ -250,6 +203,82 @@
         exitWithSuccess(options);
     }
 
+    private static void printCliSettings(String gradleHome, StartParameter startParameter) {
+        logger.debug("gradle.home= " + gradleHome);
+        logger.debug("Project dir: " + startParameter.getCurrentDir());
+        logger.debug("Gradle user home: " + startParameter.getGradleUserHomeDir());
+        logger.info("Recursive: " + startParameter.isRecursive());
+        logger.info("Buildfilename: " + startParameter.getBuildFileName());
+        logger.debug("Plugin properties: " + startParameter.getPluginPropertiesFile());
+        logger.debug("Default imports file: " + startParameter.getDefaultImportsFile());
+    }
+
+    private static boolean processProjectDir(StartParameter startParameter, OptionSet options) throws IOException {
+        if (options.has(PROJECT_DIR)) {
+            startParameter.setCurrentDir(new File(options.argumentOf(PROJECT_DIR)));
+            if (!startParameter.getCurrentDir().isDirectory()) {
+                logger.error("Error: Directory " + startParameter.getCurrentDir().getCanonicalFile() + " does not exists!");
+                exitWithSuccess(options);
+                return true;
+            }
+        } else {
+            startParameter.setCurrentDir(new File(System.getProperty("user.dir")));
+        }
+        return false;
+    }
+
+    private static void processProjectProperties(StartParameter startParameter, OptionSet options) {
+        if (options.has(PROJECT_PROP)) {
+            List<String> props = options.argumentsOf(PROJECT_PROP);
+            logger.info("Running with Project props: " + props);
+            for (String keyValueExpression : props) {
+                String[] elements = keyValueExpression.split("=");
+                startParameter.getProjectProperties().put(elements[0], elements.length == 1 ? "" : elements[1]);
+            }
+        }
+    }
+
+    private static void processSystemProperties(StartParameter startParameter, OptionSet options) {
+        if (options.has(SYSTEM_PROP)) {
+            List<String> props = options.argumentsOf(SYSTEM_PROP);
+            logger.info("Running with System props: " + props);
+            for (String keyValueExpression : props) {
+                String[] elements = keyValueExpression.split("=");
+                startParameter.getSystemPropertiesArgs().put(elements[0], elements.length == 1 ? "" : elements[1]);
+            }
+        }
+    }
+
+    private static OptionParser buildOpionParser() {
+        OptionParser parser = new OptionParser() {
+            {
+                acceptsAll(WrapUtil.toList(NON_RECURSIVE, "non-recursive"), "Do not execute primary tasks of childprojects.");
+                acceptsAll(WrapUtil.toList(NO_JVM_TERMINATION), "Don't trigger a System.exit(0) for normal termination. Used for Gradle's internal testing.");
+                acceptsAll(WrapUtil.toList(NO_DEFAULT_IMPORTS, "no-imports"), "Disable usage of default imports for build script files.");
+                acceptsAll(WrapUtil.toList(NO_SEARCH_UPWARDS, "no-search-upward"), "Don't search in parent folders for a settings.gradle file.");
+                acceptsAll(WrapUtil.toList(NO_CACHING, "no-caching"), "No caching of compiled build scripts.");
+                acceptsAll(WrapUtil.toList(VERSION, "version"), "Print version info.");
+                acceptsAll(WrapUtil.toList(DEBUG, "debug"), "Log in debug mode (includes normal stacktrace).");
+                acceptsAll(WrapUtil.toList(QUIET, "quiet"), "Log errors only.");
+                acceptsAll(WrapUtil.toList(IVY_DEBUG, "ivy-debug"), "Set Ivy log level to debug (very verbose).");
+                acceptsAll(WrapUtil.toList(IVY_QUIET, "ivy-quiet"), "Set Ivy log level to quiet.");
+                acceptsAll(WrapUtil.toList(STACKTRACE, "stacktrace"), "Print out the stacktrace also for user exceptions (e.g. compile error).");
+                acceptsAll(WrapUtil.toList(FULL_STACKTRACE, "full-stacktrace"), "Print out the full (very verbose) stacktrace for any exceptions.");
+                acceptsAll(WrapUtil.toList(TASKS, "tasks"), "Show list of all available tasks and there dependencies.");
+                acceptsAll(WrapUtil.toList(PROJECT_DIR, "project-dir"), "Specifies the start dir for Gradle. Defaults to current dir.").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(GRADLE_USER_HOME, "gradle-user-home"), "Specifies the gradle user home dir.").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(PLUGIN_PROPERTIES_FILE, "plugin-properties-file"), "Specifies the plugin.properties file.").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(BUILD_FILE, "buildfile"), "Specifies the build file name (also for subprojects). Defaults to build.gradle.").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(SYSTEM_PROP, "systemprop"), "Set system property of the JVM (e.g. -Dmyprop=myvalue).").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(PROJECT_PROP, "projectprop"), "Set project property for the build script (e.g. -Pmyprop=myvalue).").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(EMBEDDED_SCRIPT, "embedded"), "Specify an embedded build script.").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(BOOTSTRAP_DEBUG_INFO, "bootstrap-debug"), "Specify a text to be logged at the beginning (e.g. used by Gradle's bootstrap class.").withRequiredArg().ofType(String.class);
+                acceptsAll(WrapUtil.toList(HELP, "?"), "Shows this help message");
+            }
+        };
+        return parser;
+    }
+
     private static void exitWithSuccess(OptionSet options) {
         if (!options.has(NO_JVM_TERMINATION)) {
             System.exit(0);
